/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ejb.imports;

import java.io.Serializable;
import java.util.List;
import javax.ejb.EJBException;
import javax.ejb.Singleton;
import jpa.controller.PreRegistroJpaController;
import jpa.entities.PreRegistro;
import jpa.entities.ProductopreRegistro;

/**
 *
 * @author Diego Curbelo
 */
@Singleton
public class PreRegistroEJB implements Serializable{
    
    public PreRegistroEJB() {
    }

    public Integer devolverUltimoId()throws EJBException{
		List <PreRegistro> listPreRegistro;
                Integer id = null;
		listPreRegistro = new PreRegistroJpaController().findPreRegistroEntities();
		if(listPreRegistro!=null && !listPreRegistro.isEmpty()){
                    id =listPreRegistro.get(listPreRegistro.size()-1).getIdPreregistro();
                }
                return id;
    }

    public PreRegistro devolverPreRegPorId(Integer id){
        PreRegistro preReg = new PreRegistroJpaController().findPreRegistro(id);
        return preReg;
    }

   /* public void updateProdInv(Productoinventario prod)throws EJBException{
        try {
            new ProductoinventarioJpaController().edit(prod);
        } catch (IllegalOrphanException ex) {
            Logger.getLogger(ProductPreRegEJB.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NonexistentEntityException ex) {
            Logger.getLogger(ProductPreRegEJB.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(ProductPreRegEJB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public void registrarProducto(Productoinventario prod)throws EJBException{
        try {
            new ProductoinventarioJpaController().create(prod);
        } catch (Exception ex) {
            Logger.getLogger(ProductPreRegEJB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }*/
 
}
